package com.oig.sys.auth.dto;


import com.fasterxml.jackson.annotation.JsonFormat;
import com.oig.common.validator.GroupAdd;
import com.oig.common.validator.GroupChange;
import com.oig.common.validator.GroupEdit;
import io.swagger.v3.oas.annotations.media.Schema;

import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.util.Date;
import java.util.List;

@Data
@Schema(description = "用户信息参数类")
public class UserDto {

    @Schema(description = "主键id", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    @NotNull(message = "参数错误,id不能为空", groups = {GroupEdit.class})
    private Integer id;
    @Schema(description = "登录账户", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    @NotEmpty(message = "参数错误，用户账户不能为空", groups={GroupAdd.class, GroupEdit.class})
    @Pattern(message = "参数错误，用户账户由字母数字组成", regexp = "[A-Za-z0-9_]{3,32}", groups = {GroupAdd.class, GroupEdit.class})
    private String username;

    @Schema(description = "密码", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    @NotEmpty(message = "参数错误，密码不能为空", groups={GroupChange.class})
    @Pattern(message = "参数错误，密码由字母数字下划线组成",regexp = "[A-Za-z0-9_!~#]{6,32}", groups = {GroupChange.class})
    private String password;

    @Schema(description = "原密码", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    @NotEmpty(message = "参数错误，原密码不能为空", groups={GroupChange.class})
    @Pattern(message = "参数错误，原密码由字母数字下划线组成",regexp = "[A-Za-z0-9_!~#]{6,32}", groups = {GroupChange.class})
    private String oldPassword;


    @Schema(description = "别名", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    @NotEmpty(message = "参数错误，别名不能为空", groups={GroupAdd.class, GroupEdit.class})
    private String nickName;

    @Schema(description = "工号")
    //@NotEmpty(message = "参数错误，用户工号不能为空")
    private String code;

    @Schema(description = "手机号")
    private String phone;

    @Schema(description = "e-mail")
    private String email;

    @Schema(description = "真实姓名或中文名", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    @NotEmpty(message = "参数错误，姓名不能为空", groups={GroupAdd.class, GroupEdit.class})
    private String realName;
    @Schema(description = "性别")
    private String sex;

    @Schema(description = "生日")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date birthday;

    @Schema(description = "学历")
    private String education;
    @Schema(description = "毕业院校")
    private String school;

    @Schema(description = "毕业时间")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date graduationDate;

    @Schema(description = "租户id", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    @NotNull(message = "参数错误,租户id不能为空", groups={GroupAdd.class, GroupEdit.class})
    private Integer tenantId;
    @Schema(description = "租户编码")
    private String tenantCode;
    @Schema(description = "租户名称")
    private String tenantName;



    @Schema(description = "默认进入的子系统")
    private Integer defaultSysId;
    @Schema(description = "默认进入的子系统名称")
    private String defaultSysName;
    @Schema(description = "默认进入的子系统图标")
    private String defaultSysImgUrl;

    @Schema(description = "最后一次登录id")
    private String lastLoginIp;

    @Schema(description = "状态")
    private String status;
    @Schema(description = "飞书用户id")
    private String feishuUserId;

    @Schema(description = "所属部门列表,配置用户所属部门，只需传部门id")
    private List<DepartmentDto> departmentList;

    @Schema(description = "岗位职务列表,配置用户岗位，只需传岗位id")
    private List<JobDto> jobList;

    @Schema(description = "角色列表,配置角色权限，只需传角色id")
    private List<RoleDto> roleList;
}
